﻿using System;

using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace IFD2
{
    public partial class OrderContact : System.Web.UI.Page
    {
        private string[] sSplited;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                lblError.Text = "";
                return;
            }
            else
            {
                if (Session["ACL"].ToString().IndexOf("SA4") < 0)
                {
                    Response.Redirect("unauthorized.aspx");
                }
            }

            //if (!IsPostBack)
            //if(Request["lstRequestType"]=="B" || Request["lstRequestType"]=="H")
            //{
            //    lblError.Text=Request["lstRequestType"];
            //}

            if (Session["GROUP_BOOK"].ToString() == "True" && Session["ACL"].ToString().IndexOf("BD3") >= 0)
            {
                chkIsGroup.Checked = false;
                chkIsGroup.Enabled = true;
            }
            else
            {
                chkIsGroup.Checked = false;
                chkIsGroup.Enabled = false;
            }


            butNext.Attributes.Add("onclick", "javascript:return confirm('Are you sure?');");
            //if(PreviousPage.ClientQueryString!="xxx.aspx")

            try
            {
                DateTime DepTime, ArrTime, LastArrTime;
                TimeSpan span;// = new TimeSpan(0, 0, 0);
                int link_time;
                string sTmp;
                int adt_count, chd_count, inf_count, trip_count;

                if (Session["EMAIL"] != null)//为方便修改操作，自动用上次的联系人填写？
                {
                    txtContactMan.Text = Session["CONTACT_MAN"].ToString();
                    txtMobilePhone.Text = Session["MOBILE"].ToString();
                    txtPhone.Text = Session["PHONE"].ToString();
                    txtAddress.Text = Session["ADDRESS"].ToString();
                    txtEmail.Text = Session["EMAIL"].ToString();
                    txtPostCode.Text = Session["POST_CODE"].ToString();
                }
                if (Session["TRIP_COUNT"] == null)
                {
                    butNext.Enabled = false;
                    lblError.Text = "Illegal Post!";
                    return;
                }
                trip_count = Convert.ToInt16(Session["TRIP_COUNT"].ToString());
                adt_count = Convert.ToInt16(Session["ADT_COUNT"].ToString());
                chd_count = Convert.ToInt16(Session["CHD_COUNT"].ToString());
                inf_count = Convert.ToInt16(Session["INF_COUNT"].ToString());
                lblAdtCount.Text = adt_count.ToString();
                lblChdCount.Text = chd_count.ToString();
                lblInfCount.Text = inf_count.ToString();

                LastArrTime = Convert.ToDateTime("1900-1-1");
                for (int i = 1; i <= trip_count; i++)
                {
                    sTmp = Request.Form["KEY" + i.ToString()];
                    if (sTmp == null)
                    {
                        lblError.Text = "Please select your desired fare for each trip segment.";
                        butNext.Enabled = false;
                        return;
                    }
                    //check link time....
                    sSplited = sTmp.Split('|');

                    Session["FLT_DATE" + i.ToString()] = sSplited[0];
                    Session["FLT_NO" + i.ToString()] = sSplited[2];
                    Session["AIRLINE" + i.ToString()] = sSplited[1];
                    Session["CABIN" + i.ToString()] = sSplited[5];
                    Session["CLASS" + i.ToString()] = sSplited[6];
                    Session["ORI_" + i.ToString()] = sSplited[3];//is airport,not city,if not open fare!
                    Session["DES_" + i.ToString()] = sSplited[4];
                    Session["FARE" + i.ToString()] = sSplited[7];
                    Session["DBF" + i.ToString()] = sSplited[8];
                    DepTime = Convert.ToDateTime(sSplited[9]);
                    ArrTime = Convert.ToDateTime(sSplited[10]);
                    //if (sSplited[8] == "1")//domestic = true;
                    //{
                    //    link_time = Convert.ToInt16(sSplited[11]);
                    //}
                    //else
                    //{
                    //    link_time =  Convert.ToInt16(sSplited[12]);
                    //}
                    link_time = 45;//前置检查至少要求提前半小时衔接？=系统最低衔接时间
                    span = new TimeSpan(0, link_time, 0);
                    if (sSplited[2] != "OPEN" && i > 1)//need to check link time
                    {
                        if (DepTime - LastArrTime < span)
                        {
                            lblError.Text = sSplited[3] + "-" + sSplited[4] + ": Connecting time is not enough!";
                            butNext.Enabled = false;
                            break;
                        }
                    }
                    if (sSplited[2] != "OPEN")
                        LastArrTime = ArrTime;

                }
            }
            catch (Exception ex)
            {
                if (Application["DEBUG"].ToString() == "1")
                    lblError.Text = ex.Message;
                else
                    lblError.Text = "Unexpected error! Please recheck the input/output data first. If the error appears again, contact adminstrator with your operating details please.";
            }
        }

        protected void butNext_Click(object sender, EventArgs e)
        {
            //if (Application["DEBUG"].ToString() == "0")//压力测试时不判断是否机器人！
            //{
                if (txtImgCode.Text.ToLower() != Session["CHK_CODE"].ToString())
                {
                    lblError.Text = "Please input the check code!";
                    txtImgCode.Text = "";
                    return;
                }

                if (IsRobot.Test("Book", 20, 600, 5))//检测操作频次，太频繁则认为是机器人
                {
                    lblError.Text = "Please don't book continually!";
                    return;
                }
            //}
            Session["CHK_CODE"] = ((char)10).ToString();// "KLDaI*K3242L_JSD";

            txtContactMan.Text = txtContactMan.Text.Trim();
            txtMobilePhone.Text = txtMobilePhone.Text.Trim();
            if (txtContactMan.Text == "")
            {
                lblError.Text = "Please fill contact info!";
                return;
            }
            if (txtMobilePhone.Text == "")
            {
                lblError.Text = "Please fill contact info!";
                return;
            }
            //if(dlRequestType.SelectedValue=="B" && Session["ACL"].ToString().IndexOf("BD2") < 0)
            //{
            //    lblError.Text = "No authority to block request!";
            //    return;
            //}
            long new_id;
            int i, ret_code;
            int adt_count, chd_count, inf_count, trip_count;
            StringBuilder open_buf = new StringBuilder("", 10);
            StringBuilder fltno_buf = new StringBuilder("", 30);
            StringBuilder fltdate_buf = new StringBuilder("", 100);
            StringBuilder airline_buf = new StringBuilder("", 20);
            StringBuilder ori_buf = new StringBuilder("", 20);
            StringBuilder des_buf = new StringBuilder("", 20);
            StringBuilder cabin_buf = new StringBuilder("", 10);
            StringBuilder class_buf = new StringBuilder("", 10);
            StringBuilder fare_buf = new StringBuilder("", 50);
            StringBuilder dbf_buf = new StringBuilder("", 50);
            //TinyDAL dal = new TinyDAL();

            //此处用Session保存是为了方便用户重新选航班日期订座，再次进入时用上次输入的信息
            adt_count = Convert.ToInt16(lblAdtCount.Text);
            chd_count = Convert.ToInt16(lblChdCount.Text);
            inf_count = Convert.ToInt16(lblInfCount.Text);
            //Session["ADT_COUNT"] = adt_count;
            //Session["CHD_COUNT"] = chd_count;
            //Session["INF_COUNT"] = inf_count;
            Session["CONTACT_MAN"] = txtContactMan.Text;
            Session["MOBILE"] = txtMobilePhone.Text;
            Session["PHONE"] = txtPhone.Text;
            Session["ADDRESS"] = txtAddress.Text;
            Session["EMAIL"] = txtEmail.Text;
            Session["POST_CODE"] = txtPostCode.Text;

            if (Session["FLT_NO1"].ToString() != "OPEN")
            {
                try
                {
                    //SqlCommand cmd = new SqlCommand(/*"usp_get_trans_id", conn*/);
                    //cmd.CommandText = "usp_get_bk_id";//"usp_get_trans_id";
                    ////SqlParameter paraDate = new SqlParameter("@reset_date", SqlDbType.DateTime);
                    ////paraDate.Direction = ParameterDirection.Output;
                    ////cmd.Parameters.Add(paraDate);
                    //SqlParameter paraID = new SqlParameter("@curr_id", SqlDbType.BigInt);
                    //paraID.Direction = ParameterDirection.Output;
                    //cmd.Parameters.Add(paraID);
                    //SqlParameter para = cmd.Parameters.AddWithValue("@office", Session["OFFICE"].ToString());
                    //para = cmd.Parameters.AddWithValue("@airline", Session["AIRLINE"].ToString());
                    //para = cmd.Parameters.AddWithValue("@user", Session["USER"].ToString());
                    //para = cmd.Parameters.AddWithValue("@ip_addr", Request.UserHostAddress.ToString());
                    //TinyDAL.Exec(ref cmd);
                    //new_id = System.Convert.ToInt64(paraID.Value);
                    //if (new_id < 0)
                    //{
                    //    lblError.Text = "System is busy. Retry please.";
                    //    return;
                    //}
                    ////mod = new_id % 7;//目前检查重复的任务在存储过程中（同时负责计算校验码，下面代码可省），负担加大，是否不合理？
                    //Session["BK_ID"] = new_id;// *10 + mod;//记录最后一次访问的订单号

                    //改为一个存储过程，以保证完整性!
                    SqlCommand cmd = new SqlCommand();
                    SqlParameter para;
                    trip_count = Convert.ToInt16(Session["TRIP_COUNT"].ToString());
                    cmd.CommandText = "bll_bk_new";
                    cmd.Parameters.Clear();
                    SqlParameter paraID = new SqlParameter("@bk_id", SqlDbType.BigInt);
                    paraID.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(paraID);
                    //para = cmd.Parameters.AddWithValue("@trip_type", Session["TRIP_TYPE"].ToString());
                    para = cmd.Parameters.AddWithValue("@trip_count", trip_count);
                    para.SqlDbType = SqlDbType.TinyInt;
                    para = cmd.Parameters.AddWithValue("@adt_count", adt_count);
                    para = cmd.Parameters.AddWithValue("@chd_count", chd_count);
                    para = cmd.Parameters.AddWithValue("@inf_count", inf_count);
                    if (chkIsGroup.Checked)
                        para = cmd.Parameters.AddWithValue("@is_group", 1);
                    else
                        para = cmd.Parameters.AddWithValue("@is_group", 0);
                    para.SqlDbType = SqlDbType.Bit;
                    para = cmd.Parameters.AddWithValue("@contact_man", txtContactMan.Text);
                    para = cmd.Parameters.AddWithValue("@mobile_phone", txtMobilePhone.Text);
                    para = cmd.Parameters.AddWithValue("@phone", txtPhone.Text);
                    para = cmd.Parameters.AddWithValue("@email", txtEmail.Text);
                    para = cmd.Parameters.AddWithValue("@address", txtAddress.Text);
                    para = cmd.Parameters.AddWithValue("@post_code", txtPostCode.Text);
                    if (chkIsGroup.Checked)
                        para = cmd.Parameters.AddWithValue("@request_type", "H"); //团队只能后候补申请，要人工审批！
                    else
                        para = cmd.Parameters.AddWithValue("@request_type", Session["REQUEST_TYPE"].ToString()/*dlRequestType.SelectedValue*/);
                    para = cmd.Parameters.AddWithValue("@sell_airline", Session["AIRLINE"].ToString());
                    para = cmd.Parameters.AddWithValue("@sell_office", Session["OFFICE"].ToString());
                    para = cmd.Parameters.AddWithValue("@sell_user", Session["USER"].ToString());
                    para = cmd.Parameters.AddWithValue("@ip_addr", Request.UserHostAddress.ToString());
                    for (i = 1; i <= trip_count; i++)
                    {
                        //open_buf.Append(Session["OPEN" + i.ToString()] + ",");
                        fltdate_buf.Append(Session["FLT_DATE" + i.ToString()] + ",");
                        fltno_buf.Append(Session["FLT_NO" + i.ToString()] + ",");
                        airline_buf.Append(Session["AIRLINE" + i.ToString()] + ",");
                        ori_buf.Append(Session["ORI_" + i.ToString()] + ",");//此处ORI_n/DES_n已是Airport！
                        des_buf.Append(Session["DES_" + i.ToString()] + ",");
                        cabin_buf.Append(Session["CABIN" + i.ToString()] + ",");
                        class_buf.Append(Session["CLASS" + i.ToString()] + ",");
                        fare_buf.Append(Session["FARE" + i.ToString()] + ",");
                        dbf_buf.Append(Session["DBF" + i.ToString()] + ",");

                    }
                    //para = cmd.Parameters.AddWithValue("@open_buf", open_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@airline_buf", airline_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@flight_buf", fltno_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@fltdate_buf", fltdate_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@ori_buf", ori_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@des_buf", des_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@cabin_buf", cabin_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@class_buf", class_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@fare_buf", fare_buf.ToString());
                    //依据此处传入的DBF存在漏洞，此处值可用于检查，并提示用户用！
                    para = cmd.Parameters.AddWithValue("@dbf_buf", dbf_buf.ToString());
                    ret_code = TinyDAL.Exec(ref cmd);
                    switch (ret_code)
                    {
                        case 0:
                            new_id = System.Convert.ToInt64(paraID.Value);
                            Session["BK_ID"] = new_id.ToString();
                            Response.Redirect("OrderPassengers.aspx");//?pnr=" + new_id.ToString() + "&is_new=T");
                            break;
                        case 1:
                            lblError.Text = "1:Too many trips!(Max=4)";
                            break;
                        case 2:
                            lblError.Text = "2:Improper use of fare! Lost starting.";
                            break;
                        case 3:
                            lblError.Text = "3:Improper use of fare! Lost ending.";
                            break;
                        case 4:
                            lblError.Text = "4:Illegal use of fare!";
                            break;
                        case 5:
                            lblError.Text = "5:Improper use of fare! Lost middle.";
                            break;
                        case 6:
                            lblError.Text = "6:Unreasonable passenger count!";
                            break;
                        case 7:
                            lblError.Text = "7:Check city day-light-saving!";
                            break;
                        case 8:
                            lblError.Text = "8:Taxes and surcharges not found!";
                            break;
                        case 20:
                            lblError.Text = "20:Flight not found or not open!";
                            break;
                        case 22:
                            lblError.Text = "22:City timezone not found!";
                            break;
                        case 24:
                            lblError.Text = "24:Flight not open yet!";
                            break;
                        case 25:
                            lblError.Text = "25:Airport connection time info not found!";
                            break;
                        case 26:
                            lblError.Text = "26:Insufficient connecting time!";
                            break;
                        case 30:
                            lblError.Text = "30: Requested DBF fare is not matched!";
                            break;
                        case 49:
                            lblError.Text = "49:Fare not found or not applicable!";
                            break;
                        case 92:
                            lblError.Text = "92:Get new order id failed!";
                            break;
                        case 99:
                            lblError.Text = "99:Adding pending order failed!";
                            break;
                        case 100:
                            lblError.Text = "100:Adding new order failed!";
                            break;
                        case 101:
                            lblError.Text = "101:Updating class failed!";
                            break;
                        case 102:
                            lblError.Text = "102:Updating cabin failed!";
                            break;
                        case 103:
                            lblError.Text = "103:Add order trip failed!";
                            break;
                        case 104:
                            lblError.Text = "104:Cabin not found!";
                            break;
                        case 105:
                            lblError.Text = "105:Class not found!";
                            break;
                        case 106:
                            lblError.Text = "106:Class locked!";
                            break;
                        case 107:
                            lblError.Text = "107:Request only!";
                            break;
                        case 109:
                            lblError.Text = "109:No sufficient seats!";
                            break;
                        case 110:
                            lblError.Text = "110:Standing-by request failed!";
                            break;
                        case 111:
                            lblError.Text = "111:Update cabin failed!";
                            break;
                        case 112:
                            lblError.Text = "112:Update class failed!";
                            break;
                        case 113:
                            lblError.Text = "113:Insert order trip failed!";
                            break;
                        case 114:
                            lblError.Text = "114:Flight not found or closed!";
                            break;
                        case 115:
                            lblError.Text = "115:Carrier flight not found or closed!";
                            break;
                        case 150:
                            lblError.Text = "150:Re-calculate nested available failed!";
                            break;
                        case 200:
                            lblError.Text = "200:No sufficient seats!";
                            break;
                        case 201:
                            lblError.Text = "201:Target class not found!";
                            break;
                        case 202: //理论上不可能发生的错误代码
                            lblError.Text = "202:Not nested class, no sufficient seats!";
                            break;
                        case 203:
                            lblError.Text = "203:Update nested class seats failed!";
                            break;
                        case 204:
                            lblError.Text = "204:Update nested class seats failed!";
                            break;
                        case 205:
                            lblError.Text = "205:Jump to targe class failed!";
                            break;
                        case 206:
                            lblError.Text = "206:Failed to get taxes and surcharges!";
                            break;
                        case 300:
                        case 301:
                        case 302:
                        case 303:
                        case 304:
                        case 305:
                        case 306:
                        case 307:
                        case 308:
                            lblError.Text = ret_code.ToString() + ":Illegal request data!";
                            break;
                        case 309:
                            lblError.Text = "309:Can not booking passed flight!";
                            break;
                        //case 310:
                        //    lblError.Text = "310:Minus price!";
                        //    break;
                        default:
                            lblError.Text = "Error:" + ret_code.ToString();
                            break;
                    }

                    //pnr_int mypnr = new pnr_int();
                    //lblError.Text = "Your order number is " + mypnr.int2pnr(new_id * 10 + mod) + "/" + (new_id * 10 + mod).ToString();

                }
                catch (Exception ex)
                {
                    if (Application["DEBUG"].ToString() == "1")
                        lblError.Text = ex.Message;
                    else
                        lblError.Text = "Unexpected error! Please recheck the input/output data first. If the error appears again, contact adminstrator with your operating details please.";

                }
            }
            else //is open ticket. 
            {
                try
                {
                    SqlCommand cmd = new SqlCommand();
                    SqlParameter para;
                    trip_count = Convert.ToInt16(Session["TRIP_COUNT"].ToString());
                    cmd.CommandText = "bll_bk_new_open_booking";
                    cmd.Parameters.Clear();
                    SqlParameter paraID = new SqlParameter("@bk_id", SqlDbType.BigInt);
                    paraID.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(paraID);
                    //para = cmd.Parameters.AddWithValue("@trip_type", Session["TRIP_TYPE"].ToString());
                    para = cmd.Parameters.AddWithValue("@trip_count", trip_count);
                    para.SqlDbType = SqlDbType.TinyInt;
                    para = cmd.Parameters.AddWithValue("@adt_count", adt_count);
                    para = cmd.Parameters.AddWithValue("@chd_count", chd_count);
                    para = cmd.Parameters.AddWithValue("@inf_count", inf_count);
                    if (chkIsGroup.Checked)
                        para = cmd.Parameters.AddWithValue("@is_group", 1);
                    else
                        para = cmd.Parameters.AddWithValue("@is_group", 0);
                    para.SqlDbType = SqlDbType.Bit;
                    para = cmd.Parameters.AddWithValue("@contact_man", txtContactMan.Text);
                    para = cmd.Parameters.AddWithValue("@mobile_phone", txtMobilePhone.Text);
                    para = cmd.Parameters.AddWithValue("@phone", txtPhone.Text);
                    para = cmd.Parameters.AddWithValue("@email", txtEmail.Text);
                    para = cmd.Parameters.AddWithValue("@address", txtAddress.Text);
                    para = cmd.Parameters.AddWithValue("@post_code", txtPostCode.Text);
                    //para = cmd.Parameters.AddWithValue("@request_type", dlRequestType.SelectedValue);
                    para = cmd.Parameters.AddWithValue("@sell_airline", Session["AIRLINE"].ToString());
                    para = cmd.Parameters.AddWithValue("@sell_office", Session["OFFICE"].ToString());
                    para = cmd.Parameters.AddWithValue("@sell_user", Session["USER"].ToString());
                    para = cmd.Parameters.AddWithValue("@ip_addr", Request.UserHostAddress.ToString());
                    for (i = 1; i <= trip_count; i++)
                    {
                        airline_buf.Append(Session["AIRLINE" + i.ToString()] + ",");
                        ori_buf.Append(Session["ORI_" + i.ToString()] + ",");
                        des_buf.Append(Session["DES_" + i.ToString()] + ",");
                        cabin_buf.Append(Session["CABIN" + i.ToString()] + ",");
                        class_buf.Append(Session["CLASS" + i.ToString()] + ",");
                        fare_buf.Append(Session["FARE" + i.ToString()] + ",");
                        dbf_buf.Append(Session["DBF" + i.ToString()] + ",");

                    }
                    //para = cmd.Parameters.AddWithValue("@open_buf", open_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@airline_buf", airline_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@ori_buf", ori_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@des_buf", des_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@cabin_buf", cabin_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@class_buf", class_buf.ToString());
                    para = cmd.Parameters.AddWithValue("@fare_buf", fare_buf.ToString());
                    //依据此处传入的DBF存在漏洞，此处值可用于检查，并提示用户用！
                    //para = cmd.Parameters.AddWithValue("@dbf_buf", dbf_buf.ToString());
                    ret_code = TinyDAL.Exec(ref cmd);
                    switch (ret_code)
                    {
                        case 0:
                            new_id = System.Convert.ToInt64(paraID.Value);
                            Response.Redirect("OrderPassengers.aspx?pnr=" + new_id.ToString() + "&is_new=T");
                            break;
                        case 1:
                            lblError.Text = "1:Too many trips!(Max=4)";
                            break;
                        case 2:
                            lblError.Text = "2:Improper use of fare! Lost starting.";
                            break;
                        case 3:
                            lblError.Text = "3:Improper use of fare! Lost ending.";
                            break;
                        case 4:
                            lblError.Text = "4:Illegal use of fare!";
                            break;
                        case 5:
                            lblError.Text = "5:Improper use of fare! Lost middle.";
                            break;
                        case 6:
                            lblError.Text = "6:Too many passengers!";
                            break;
                        case 7:
                            lblError.Text = "7:Check city day-light-saving!";
                            break;
                        case 8:
                            lblError.Text = "8:Taxes and surcharges not found!";
                            break;
                        case 20:
                            lblError.Text = "20:Flight not found or invalid status!";
                            break;
                        case 22:
                            lblError.Text = "22:Origin city day-light-saving info not found!";
                            break;
                        case 24:
                            lblError.Text = "24:Flight not open yet!";
                            break;
                        case 25:
                            lblError.Text = "25:Airport link time info not found!";
                            break;
                        //case 29:
                        //    lblError.Text = "29:Stay days not satisfied!";
                        //    break;
                        case 30:
                            lblError.Text = "30: Requested DBF fare is invalid!";
                            break;
                        case 49:
                            lblError.Text = "49:Fare not found!";
                            break;
                        case 99:
                            lblError.Text = "99:Adding pending order failed!";
                            break;
                        case 100:
                            lblError.Text = "100:Adding new order failed!";
                            break;
                        case 101:
                            lblError.Text = "101:Updating class failed!";
                            break;
                        case 102:
                            lblError.Text = "102:Updating cabin failed!";
                            break;
                        case 103:
                            lblError.Text = "103:Add block order trip failed!";
                            break;
                        case 104:
                            lblError.Text = "104:Cabin not found!";
                            break;
                        case 105:
                            lblError.Text = "105:Class not found!";
                            break;
                        case 106:
                            lblError.Text = "106:Class blocked!";
                            break;
                        case 107:
                            lblError.Text = "107:Request only!";
                            break;
                        case 109:
                            lblError.Text = "109:No sufficient seats!";
                            break;
                        case 110:
                            lblError.Text = "110:Standing-by request failed!";
                            break;
                        case 111:
                            lblError.Text = "111:Blocking cabin failed!";
                            break;
                        case 112:
                            lblError.Text = "112:Blocking class failed!";
                            break;
                        case 113:
                            lblError.Text = "113:Add order trip failed!";
                            break;
                        case 114:
                            lblError.Text = "114:Flight not found!";
                            break;
                        case 150:
                            lblError.Text = "150:Re-calculate nested available seats failed!";
                            break;
                        case 200:
                            lblError.Text = "200:No sufficient seats!";
                            break;
                        case 201:
                            lblError.Text = "201:Class not found!";
                            break;
                        case 202:
                            lblError.Text = "202:Insufficient nested seats";
                            break;
                        case 203:
                            lblError.Text = "203:Nesting class seats failed!";
                            break;
                        case 204:
                            lblError.Text = "204:Nesting class seats failed!";
                            break;
                        case 206:
                            lblError.Text = "206:Failed to get taxes and surcharges!";
                            break;
                        case 300:
                        case 301:
                        case 302:
                        case 303:
                        case 304:
                        case 305:
                        case 306:
                        case 307:
                        case 308:
                        case 309:
                            lblError.Text = ret_code.ToString() + ":Illegal request data!";
                            break;
                        case 310:
                            lblError.Text = "There is at least one age price is not available!";
                            break;
                        default:
                            lblError.Text = "Error:" + ret_code.ToString();
                            break;
                    }

                    //pnr_int mypnr = new pnr_int();
                    //lblError.Text = "Your order number is " + mypnr.int2pnr(new_id * 10 + mod) + "/" + (new_id * 10 + mod).ToString();

                }
                catch (Exception ex)
                {
                    if (Application["DEBUG"].ToString() == "1")
                        lblError.Text = ex.Message;
                    else
                        lblError.Text = "Unexpected error! Please recheck the input/output data first. If the error appears again, contact adminstrator with your operating details please.";

                }
            }

        }
        //protected void btnChgImg_Click(object sender, EventArgs e)
        //{
        //    txtImgCode.Text = "";
        //    //imgCode.ImageUrl = "";
        //    //imgCode.ImageUrl = "~/img_chk.aspx";
        //    //Response.Redirect("~/bk_base_info.aspx");
        //    Random rd = new Random();
        //    Image1.ImageUrl = "img_chk.ashx?" + rd.Next().ToString();
        //}
    }
}